import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	
	private static Scanner sc = new Scanner(System.in);
	static ArrayList<Integer> ordersList = new ArrayList<Integer>();

	public static void main(String[] args) {
		
		int choice=0;
		while (choice != 4) {
			System.out.println("1. Display Menu");
			System.out.println("2. Submit New Order");
			System.out.println("3. Display Latest Tab");
			System.out.println("4. Exit");
			choice = sc.nextInt();
			programLoop(choice);
		}
		
		

	}
	
	public static void programLoop(int choice) {
		
		if (choice==1) {
			Waiter newMenu = Server.getMenu();
			DisplayMenu menu = new DisplayMenu(newMenu);
			OnWait getMenu = new OnWait(menu);
			getMenu.serve();
		}
		if (choice==2) {
			ordersList = new ArrayList<Integer>();
			int c = 0;
			System.out.println("Please select the dishes you would like to order. Exit by entering a number not on the list.");
			while (choice > 0 && choice < 6) {
				choice = sc.nextInt();
				if (choice > 0 && choice < 6)
					ordersList.add(choice);
				c++;
			}
			Waiter newOrder = Server.createOrder(ordersList);
			SubmitOrder order = new SubmitOrder(newOrder);
			OnWait getOrder = new OnWait(order);
			getOrder.serve();
		}
		if (choice==3) {
			Waiter newTab = Server.getTab(ordersList);
			DisplayTab tab = new DisplayTab(newTab);
			OnWait getTab = new OnWait(tab);
			getTab.serve();
		}
		if(choice==4) {
			System.exit(0);
		}
	}

}
